#pragma once

#include <QColor>
#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
#include <QMouseEvent>
#include <QPoint>
#include <map>
#include <vector>

#include "STreeComboBox.h"
#include "widgets.h"

class SImageButton;
class S_WIDGETS_EXPORT SFilterTree : public QFrame {
  Q_OBJECT
 public:
  SFilterTree(QWidget* p, bool showClear = true, bool showInvert = true,
              QString strColor = "BackNormal",
              QString strBorderColor = "Highlight", int itemHeight = 24,
              int dropHeight = 200);

  void setName(const QString& sName);
  void setNameWidth(int width);
  void setDefaultString(const QString& strDefault);
  void setDropFixedWidth(int width);
  void setLeftOffset(int left);
  void setTreeData(STreeData& treeData);
  void setTreeEnable(bool enable);
  void setComboStyleSheet(const QString& stylesheet);

  void clearSelect();
  const QStringList& getSelectItemData();

 Q_SIGNALS:
  void filterChanged();

 protected Q_SLOTS:
  void onBtnClick();
  void onTreeItemSelectChanged();

 protected:
  void paintEvent(QPaintEvent* event) override;

 private:
  QHBoxLayout* m_layout = nullptr;
  STreeComboBox* m_tree = nullptr;
  SImageButton* m_btnClear = nullptr;
  QString m_name;
  int m_nameWidth;
  int m_leftOffset;
  bool m_bSignFromParent;
};
